package com.boot.springbootdemo.controller;

import com.boot.springbootdemo.bean.Car;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class HelloController {

    @Autowired
    private Car car;

    @RequestMapping("/car22")
    public Car car(){
        return car;
        //{"brand":"XXX","price":10000}
    }

    // http://localhost:8080/jz/path;name=zs;age=20;xq=c,h,w,l
    // TODO 矩阵 @MatrixVariable 必须有路径变量{} 开启 urlPathHelper.setRemoveSemicolonContent(false);
    @GetMapping("/jz/{path}")
    public Map getOne(@MatrixVariable("name") String name, @MatrixVariable("age")Integer age, @MatrixVariable("xq")List<String> xq
    ,@PathVariable String path){
        Map<String, Object> map = new HashMap<>();
        map.put("n",name);
        map.put("a",age);
        map.put("x",xq);
        map.put("path",path);
        return map;
    }
}
